<template>
<<<<<<< HEAD
    <div class="subconnumber">
        <div @click='subtraction' class="left">-</div>
        <div class="center">{{count}}</div>
        <div @click='addition' class='right'>+</div>
    </div>
</template>

<script>
export default {
    data(){
        return{
            count:1
        }
    },
    methods:{
        subtraction(){
            this.count--;
            if(this.count<=0){
                this.count=0
            }
            this.sendmessage()
        },
        addition(){
            this.count++;
            this.sendmessage()
        },
        sendmessage(){
            this.$emit('dataobj',this.count)
        }
    }


}
</script>

<style scoped>
    .subconnumber div{
        display: inline-block;
        width: 50px;
        height: 25px;
        border: 1px solid #000;
        text-align: center;
        line-height: 25px;
        border-radius: 5px;
    }
    .subconnumber{
        position: absolute;
        top: 5px;
        left: 100px;
    }
</style>
=======
	<div id="subtmpl">
		<div class="inleft div" @click="substrict">-</div>
		<div class="incenter div" v-text="count"></div>
		<div class="inright div"  @click="add">+</div>
	</div>
</template>

<script>
	export default{
		data(){
			return {
				count :1 //代表购买商品的数量
			}
		},
		methods:{
			substrict(){
				this.count--;
//				确保最小值为1
				if(this.count <1){
					this.count = 1;
				}
				this.sendmessage();
			},
			add(){
				this.count++;
				this.sendmessage();
			},
			sendmessage(){
				this.$emit('dataobj',this.count);
			}
		}
	}

</script>

<style scoped>
	#subtmpl .div{
		width: 40px;
		height: 25px;
		line-height: 25px;
		border: 1px solid #000;
		display: inline-block;
		text-align: center;
	}

</style>
>>>>>>> 52bb90ba34f266b253fe08348978af58b2266aab
